/*
 * Copyright (c) 2011 Auzingers
 * Created by Oui-IT
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 */
package com.auzingers.docsorganizer.entity;

import java.util.List;

/**
 * Class that represents the result of i.e. a google documents query. Contains the actual documents and collections
 * returned and additional header data.
 */
public class GoogleResult {

    private List<GoogleEntry> entries;

    /** Startkey for next query (when paging). */
    private String nextStartKey;

    /** Google author quering the feed. */
    private GoogleAuthor feedAuthor;

    public List<GoogleEntry> getEntries() {
        return entries;
    }

    /**
     * Sets the given entries and also updates the shared entry flag of the given entries.
     * @param entries entries to set
     */
    public void setEntries(List<GoogleEntry> entries) {
        this.entries = entries;
        for (final GoogleEntry entry : entries) {
            if (entry.getAuthor() != null && !entry.getAuthor().equals(feedAuthor)) {
                entry.setSharedEntry(true);
            } else {
                entry.setSharedEntry(false);
            }
        }
    }

    public String getNextStartKey() {
        return nextStartKey;
    }

    public void setNextStartKey(String nextStartKey) {
        this.nextStartKey = nextStartKey;
    }

    public GoogleAuthor getFeedAuthor() {
        return feedAuthor;
    }

    public void setFeedAuthor(GoogleAuthor feedAuthor) {
        this.feedAuthor = feedAuthor;
    }
}
